Mahi fx rebased

Rabaed @mahileeb's pull-request #5 to my #13. @mahileeb: Could you have a look at it whether I broke anything.