Fixed #275 - better handling of galleries

Before & after shot:

![gallery](https://f.cloud.github.com/assets/3903757/1779180/c76dba44-6842-11e3-80ad-9a63ef37d028.png)