Added functionality to automatically delete old kernels from the system, also cleaned up code