code refactorings

Hi Andy,
I know it is a pain, but I can't seem to commit to master in eaterprises.