More efficient memory use in future implementation

Repeated future::map function calls create a long chain of promise/future pairs. When the future is fulfilled, call to the mapping function might consume up the stack. To avoid stack overflow, this pull request implements manual tail call optimization.