Removed static stuff, and add in function rewriting