Code and grammar cleanup