fixed some errors and a missing flag