some optimizations; go fmt