added support for setting rpc script name and port number, plus some code cleanup

#fno-138 in progress