Clean and Wake On Plug

This is taken from AOKP and this commit: 692d590554b70db15f9add73f1e8ec397aa0b8e0 - with a couple of alterations.