Fixes js errors

Fixes some JS errors i came across while using this. 

I believe also fixes the raised issue here:
https://github.com/alexharris/octopress-flat/issues/5