lots of syntax and minor logic errors
added upsertInstance method into category model
second part of bugs festival
and third part of freaking pile of fixes...