Cleaning up code and add Pool class