Code cleanup. Adapter pattern, better credential management. Still needs work