Fixes for numerous github issues