Add more error checking
Changed license to LGPL