cleaning it up and bug fixes