The timing library code assumes a 4 MHz clock and is PIC specific. Make more flexible. One possibility is to write a Perl script to generate the appropriate code. But still, this can be very compiler specific.