Bugfixes and pattern packing ugly test.