Revert "24/7/2013"

This reverts commit eceab4acf6638be35f98c73afcdba08fd0ae112b.
Mass Commit 20/8/2013

Some new functions in library.php and fixing various files