some refactoring to cope with plans for wifi functionality (coming soon
(tm))