Fixed regexp offset and added exception if server template code is empty