Add deleted functionality and clean up code