Fixed "undefined offset" issues #119 #118