Fixing memory leak and tweaks to style