Fix server hang issues

Closes #10 and resolves #4