cleaned up code; minor style tweaks