Fix some errors & bugs