Fix uptime and minor re-factoring