Main method bug fixes