Refactored code
Computes the current time
Implemented main system loop, with clean, easily maintainable code :)