Changes to init sequence to ensure that all used pins are initialised BEFORE peripherals are configured.  This is to ensure that odd interactions do not occur.

Also contiki-fied some code so it is closer to the coding guidelines.