changes to allow append to happend + some bug fixes