fixed error and some warnings