Merge pull request #4 from csanquer/master

Some fixes and minor optimizations