removes legacy code
moves and simplifies code
simplifies more code