Changed error type
Memory usage improvements