added null checks
removed use of deprecated methods
bugzid 5175: set regionId of template properly
Merge pull request #29 from daniellemayne/2014.08

2014.08: added null checks and bugfix 5175