Model improvements and bug fixes