Need to check the ticket state later on.
Small cleanup, and comments added.
Check for site_id collision, and ask for a bug report.