Fixed insertion debug log, made save code more robust