Refactor, re-arrange, and correct a few functions for missing paramaters.  Still a few to catch