Several little changes. Now, the main function is outer to ".l" file