Implemented S and Z pieces and refactored model.