Re-written client

Improved delegation logic and prime algorithm,