Fixes for issues: #19 #526 and #612