Implemented new code request token generation method

This is working now. However some more testing would be nice before pulling.