Pulling @nielin's fixes into master

Thanks for the fixes, @nielin !