Bugfix for no sysclose method

Fixes bug #6, tested both with and without SSL. Also some styling fixes.