Optimize getAccounts() and getTopAccounts(), fix removing accounts