Merge pull request #171 from diegocr/master

Various fixes and improvements.