Cleaned up code - last stable