Added support for different file types. 

Just redoing the great work that @jede had done, just from a recent fork.