Code cleanup

Various small cleanups