cleaned up code, minimal working clock