Cleaned up code post codereview