Almost all updated code