Code cleanup and style optimizing