Better append and delete functionality. Misc bug fixes