Made code work again

Made several changes without a working enviornment, this is the fix for
the problems introduced