Clean up code; fix bad style issues