Added initial support for background mode (not working)