Blocks out of bounds both ways - and I improved undo + added comments

Comments explain reindexing