Cleaned up connection.js and fixed undefined data (I hope)