added on-boot functionality and optimized a bit