fixed many a bug