Several fixes, added whitelist check