fixed a lot of 1-based index errors. Added examples