Added getError() function
Bug fixes