Fix some model implementation bugs