fixed bug and added mempool support

Signed-off-by: James Paton <jpaton2@gmail.com>