code cleanup and simplifications