fix build and bugs