Starting to move charges controller logic into a module
Incorporated Najee's most recent changes