Source cleanup

Various small fixes to clean up the source.