add getting power-state info; clean up code;