small changes from @dorimanx branch.