Fix entities; implement repositories