Added necessary code from other libraries