some little cleanup and optimization