fixed bug in compact() that was causing empty arrays and objects to not be removed