Fixed several bugs in optsrv executable