fix load errors
fix typo
many updates and fixes

Created and documented sub functions so loop() doesn't look like such a
mess