Implement $q on DynamoDB object and event hooks on login/logout

Also fixes issue #1