Clean up publish activity

Moved publishing to a background thread to make ui smoother.