some unit tesing, some code cleanup, some model changes