Changed shape representation and added key processing