memory bug fixes; fix model associations bug