Implemented feedback review comments, removing hard coded values and adding error handling.
More cleanup.