Completed (but buggy) functions.