clean up and compat fixes

fixed some functions to be compatible with this cms and did some cleanup to make it more streamlined.
Merge pull request #3 from chrisx84/patch-1

clean up and compat fixes