Add postgresql events queue implementation.
Minor fixes and typo fixes inteoduced in previous refactors.