Implemented main system loop, with clean, easily maintainable code :)