Clean-up code

Clean up code, create proper functions and do things a bit more
efficient. Also squashed a bug with reading the hour value from DS1307,
it seems.