Various tweaks, fixes and cleanups

Better use of config, cleanup unused code, fixes to notes (still needs
work), closed a lot of connections (that previously caused too many
connections error)