Add some extra logic to fix #47

This should be tested with these forms: https://gist.github.com/BronsonQuick/5334350.

I still want to come back one day and refactor all of this functions and filters but this should do the trick in the meantime.

@tareiking #reviewmerge