fix code and warnings