bug fixing and documentation