Firts set of fixes for #46