Model connection and bug fixes