Fix some bugs with the key mask.

Signed-off-by: Tyler O'Meara <Tyler@TylerOMeara.com>