Moved most JS outside of ready function