Bugfix and style correction

- Fixed some bugs with the tick handler
- Fixed the code style in main.c