Moved main code to __main__