Added errors, mem safety, allocation, and deallocation