Fixed some serious bugs by adding some test models and scripts.