add optional module dependency

..and fix segfault (see https://gist.github.com/Bittarman/7f45618c4efabb0612bd)