Fixed bug and improved function

http://www.8.php-fusion.net/infusions/roadmap/view.php?item_id=1146
http://www.php-fusion.co.uk/forum/viewthread.php?thread_id=33950