Abstracted lang functions and code cleanup