code clean up and added timer stuff