Error fixes with a little new code