Redo all changes I ended up losing trying to undo the mess I made.
Also, fix the issue pointed out by Alam.