most of model ported; needs serious debugging