cleanup unused elements and bad code