Bug fixes for the main and pg js.