Code cleanup and layout prettifying