Improve PostgreSQL start waiting code