Code Restructuring

- Moved timer code into a standalone module
- Added Pub Sub code
- Moved functions and constants out of global scope