cleaned up code from the pull requests