COSM integration, separation of library and script

Please take a look at some changes I did and feel free to merge them if you find them useful. Major ones:

1. Separated command line script from library, so the library could be used by other scripts
2. Added script to upload nest data to COSM.com 

Vadim