Fixin numerous bugs