remove unused legacy code and clean comments