fixed some bugs, added model scoping