Attempted fix of bugs