Removed all old unused APIs. Made the error messages more consistant. Fixed some bugs.