Fix for SPAs, general cleanup.