Changed to long's solution wide.
Added userfriendly input methods and checks, included _DEBUG checks, changed malloc and free wrappers.