Improved ace logic, cleaned up code a bit