Added some bit twiddling functions
Started cleanup of device binding