Write and delete records implementations

- Insert record implementation
- Cleanup of readpage and flushpage
- Other minor cleanup/fixes