Resolved memory leaks. Implemented parting, error codes.