Fixed some code ugliness