Break out more functions into new namespace and re-arrange functions more logically