rearranged states welcome & init, added debug function
replaced delay() with a timer implementation