Refactoring and cleanup.
Adding version api number to connection.
Added (hopefully) high performance counter.