More task accounting fixes.

 - Refactored the internal task state
 - Added task lanch rate limiting