Modified for easy include in other libraries