Added unit tests
- Added more memory protection features
- Fixed various bugs