Performance updates to MySQL writes

Changed flow of inserts and updated shell scripts to automatically
determine location