Fix style issues, improve performance, remove junk