simplify publication code with a new DB field

For timed publications, the workarounds being used were quite ugly.
Do not use them anymore. Instead, add a new DB field to save whether
a release has been explicitly published to the DB table. Ensure this
before every API call.

More code cleanup, removal of debug code, syntax error fixes etc.