small optimizations, insert spaces where necessary