Finalized bug fixing