Put some debugging and safety nets here and there