major refactor/cleanup to allow clean socket options