Updated but should be moved
Updating to use ConnectionManager and cleaning up code.