Cleaned up ATB code