I fail at variable declarations. Also, added clock to make control loop more uniform.