Cleaned up login

All tasks use a common function to generate and execute tasks
Core function that creates tasks refactored to accept domain as argument