Added additional validations and callback methods to layout

I added certain additional validations in regards to whether the deletion should happen as well as fixing a bug of calling deleting index too soon.