Fix code and build process