safety check before init and some tidy work
Merge pull request #22 from ccheetham/master

safety check before init and some tidy work