fixed small syntax error
many small bug fixes