some cleanup and redundant code removal