Fix various bugs preventing use of the module.