clean up and optomizations