More fixed for #36, also did similar fixes in the code base