Removed incorrect error message and some general code cleaning.