Some fixes and documentation. Should look into error code 5.