Changed from compact representation to B-P representation. This wastes some space, but code is more clear.