polonaise: Fix leaks and start testing polonaise with valgrind

Change-Id: Ib50a63ee55a283677f1a44b7401184395a9b6c34