AVM1 stdlib improvements

Plus some cleanup.