Merges Sergeys Changes, added some more functions and extensions