Fixes coding style and does some cleanup